package org.skyeye.modeling.tools;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.skyeye.modeling.Activator;

/**
 * The logger of convenience for the skyeye plug-in.
 */
public class SkyeyeLog {
	/**
	 * Log the specified information.
	 * 
	 * @param message
	 */
	public static void logInfo(String message) {
		log(IStatus.INFO, IStatus.OK, message, null);
	}

	/**
	 *
	 * @param severity
	 * @param code
	 * @param message
	 * @param exception
	 */
	private static void log(int severity, int code, String message, Throwable exception) {
		log(createStatus(severity, code, message, exception));
	}

	/**
	 * log the given status
	 * 
	 * @param status
	 */
	private static void log(IStatus status) {
		Activator.getDefault().getLog().log(status);
	}

	/**
	 * Create a status object representing the specified information.
	 * 
	 * @param severity
	 * @param code
	 * @param message
	 * @param exception
	 * @return
	 */
	private static IStatus createStatus(int severity, int code, String message, Throwable exception) {
		return new Status(severity, Activator.PLUGIN_ID, code, message, exception);
	}

	/**
	 * Log the specified error.
	 * 
	 * @param exception,
	 *            a low-level exception.
	 */
	public static void logError(Throwable exception) {
		logError("Unexpected Exception", exception);
	}

	/**
	 * Log the specified error.
	 * 
	 * @param message
	 * @param exception
	 */
	public static void logError(String message, Throwable exception) {
		log(IStatus.ERROR, IStatus.OK, message, exception);
	}
}
